print("姓名:袁兆华 学号:20190751028")
print('作业如下:')
print("1.求出所有3位数的水仙花数")
import math
def fun():
    for i in range(100, 1000):
        if math.pow((i % 10), 3) + math.pow((i // 10 % 10), 3) + math.pow((i // 100), 3) == i:
            print("水仙花数为:", i)
if __name__ == '__main__':
    fun()
print()

print('2.编写程序，10000元本金，每年利息收入7%，多少年后本金超过13000')
def fun():
    money = 10000
    i = 0
    while True:
        money = money + money * 0.07
        print(money)
        i += 1
        print(i)
        if money > 13000:
            break
    print(f"10000的本金在\033[0:35m{i}\033[m年后本金会超过13000!!!")
if __name__ == '__main__':
    fun()
print()

print('3.求200~500之间所有的素数，然后10个一行，最后求总和')
primes = []
for n in range(200, 501):
    for j in range(2, int(math.sqrt(n)) + 1):
        if n % j == 0:
            break
    else:
        primes += [n]
count = 0
for i in primes:
    print('%3d' % i, end= ' ')
    count += 1
    if count % 10 == 0:
        print(end='\n')
print()
print('素数的总个数为:',len(primes))
print('素数的总和为:',sum(primes))
print()

print('4.斐波拉契数列,定义一个n，求出第n项的值')
def fibonacci(n):
    if n < 2:
        return 1
    else:
        return fibonacci(n - 1) + fibonacci(n - 2)

if __name__ == '__main__':
    n = int(input("请输入斐波拉契函数项数:"))
    fibonacci(n)
    print(f"斐波拉契函数项数在{n}项的数为:",fibonacci(n - 1))
print()

print('5.定义函数求最大公约数和最小公倍数')
def fun(x,y):
    if x > y:
        smaller = y
    else:
        smaller = x
    for i in range(1, smaller + 1):
        if ((x %i) == 0 and (y % i) == 0):
            fun = i
    return fun
if __name__ == '__main__':
    a = int(input("请输入正整数a:"))
    b = int(input("请输入正整数b:"))
    print(f'{a} 和 {b}的最大公约数为:', fun(a, b))
    print(f"{a} 和 {b}的最小公倍数为:", int((a * b) / fun(a, b)))